import { defineStore } from "pinia"
import { Banner } from "@/models/banner"
import { bannerApi } from "@/services"

const useBannerStore  = defineStore('Banner', {
    // state
    state:() =>({
        bannerListResult: [] as Banner[]
    }),

    // actions
    actions:{
        // 获得banner列表
        async getBanners() {
            try {
                const res = await bannerApi.getBanners()
                this.bannerListResult = res? res : [] as Banner[]
            } catch(err) {
        
            }
        },
    },
    getters:{
        bannerSource:(state) => state.bannerListResult,
    }
})

export default useBannerStore;